package com.lianrui.app.member.dao;

import java.util.Map;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import com.lianrui.app.member.domain.MemberAddress;
import com.lianrui.app.member.vos.MemberAddressPage;
import com.lianrui.commons.exception.BusinessException;
import com.lianrui.core.IDao;


@Repository("memberAddressDao")
public interface IMemberAddressDao extends IDao<MemberAddressPage, MemberAddress, Integer> {
	
	@Select("select * from es_member_address where addr_id = #{id}")
	public MemberAddress unique(Integer id) throws BusinessException;
	
	@Select("select * from es_member_address where def_addr = 0 and member_id=#{member_id} ")
	public MemberAddress findDefAddr(Integer member_id);
	
	/*
	 * String sqlA="update "+getTableName("member_address")+" set def_addr=0 where member_id=?";
		String sqlB="update es_member_address set def_addr=1 where member_id=? and addr_id=?";
	 * */
	
	@Select("update  es_member_address set def_addr=0 where member_id=#{member_id}")
	public MemberAddress setDefAddr(Integer member_id);
	
	@Select("update es_member_address set def_addr=1 where member_id=#{member_id} and addr_id=#{addr_id}")
	public MemberAddress cancelDefAddr(Map<String,Integer> map);

}
